package com.one.friend.controller.user;

import com.one.common.core.constants.HttpConstants;
import com.one.common.core.controller.BaseController;
import com.one.common.core.domain.R;
import com.one.common.core.domain.TableDataInfo;
import com.one.friend.aspect.CheckUserStatus;
import com.one.friend.domain.exam.dto.ExamDTO;
import com.one.friend.domain.exam.dto.ExamQueryDTO;
import com.one.friend.service.user.IUserExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/exam")
public class UserExamController extends BaseController {

    @Autowired
    private IUserExamService iUserExamService;

    /**
     *      接口概述    竞赛报名功能
     *      接口地址    /user/exam/enter
     *      请求方法    post
     *      请求参数    ExamDTO
     *      响应数据    void
     */
    @PostMapping("/enter")
    @CheckUserStatus
    public R<Void> enter(@RequestHeader(value = HttpConstants.AUTHENTICATION) String token,@RequestBody ExamDTO examDTO){
        return toR(iUserExamService.enter(token,examDTO));
    }

    //我的竞赛列表
    @GetMapping("/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO){
        return iUserExamService.list(examQueryDTO);
    }

}
